package com.shuaigexue.exam.config;

import com.shuaigexue.exam.config.properties.MinioProperties;
import io.minio.MinioClient;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName: MinioConfiguration
 * @Description:
 * @Author: zhaoxue
 * @Date: 2025/10/28 09:57
 */
@Slf4j
@Configuration
@EnableConfigurationProperties(MinioProperties.class)
public class MinioConfiguration {


    @Resource
    private MinioProperties minioproperties;

    @Bean
    public MinioClient minioClient(){
        MinioClient minioClient = MinioClient.builder()
                .endpoint(minioproperties.getEndpoint())
                .credentials(minioproperties.getAccessKey(), minioproperties.getSecretKey())
                .build();

        log.info("MinioClient初始化成功,连接对象为:{}", minioClient);
        return minioClient;
    }
}
